home *** CD-ROM | disk | FTP | other *** search
/ Aminet 40 / Aminet 40 (2000)(Schatztruhe)[!][Dec 2000].iso / Aminet / misc / emu / ATUtilities.lha / ATUtilities / reg.c < prev    next >
C/C++ Source or Header  |  2000-09-26  |  7KB  |  215 lines

  1. #include <exec/types.h>
  2. #include <libraries/dos.h>
  3. #include <intuition/intuition.h>
  4. #include "register.h"
  5.  
  6. struct Library *ATUtilitiesBase;
  7. struct Library *GfxBase;
  8. struct Library *IntuitionBase;
  9.  
  10. VOID Kill();
  11.  
  12. VOID main()
  13. {
  14.  BOOL                          ende,bool;
  15.  UBYTE                        *vn,*nn,*st,*la,*pl,*or,*co;
  16.  UWORD                         z;
  17.  REGISTER UWORD                i,j;
  18.  REGISTER ULONG                Class;
  19.  register struct TextFont     *opal;
  20.  register struct Window       *win;
  21.  register struct RastPort     *rp;
  22.  register struct IntuiMessage *msg;
  23.  register struct Gadget       *gad;
  24.  struct FileHandle            *fh;
  25.  
  26.  bool=FALSE;
  27.  GfxBase=OpenLibrary("graphics.library",0L);
  28.  if(GfxBase==NULL) exit(0);
  29.  IntuitionBase=OpenLibrary("intuition.library",0L);
  30.  if(IntuitionBase==NULL) exit(0);
  31.  ATUtilitiesBase=OpenLibrary("at-utilities.library",0);
  32.  if(ATUtilitiesBase!=NULL)
  33.   {
  34.    win=CreateStdWindow("ATUtilities - Shareware-Registrierung",
  35.                        25,25,590,173,CLOSEWINDOW|GADGETUP,
  36.                        WINDOWCLOSE|WINDOWDRAG|WINDOWDEPTH|ACTIVATE);
  37.    if(win!=NULL)
  38.     {
  39.      rp=win->RPort;
  40.      opal=GetOpalFont();
  41.      if(opal) SetFont(rp,opal);
  42.      SelectStdFPen(rp);
  43.      CreateBoolGadget(win,15,155,150,12,"Registrieren",1);
  44.      CreateBoolGadget(win,170,155,150,12,"Abbruch",2);
  45.      CreateBoolGadget(win,420,155,150,12,"Information",3);
  46.      vn=CreateStringGadget(win,150,89,420,12,NULL,50,0);
  47.      nn=CreateStringGadget(win,150,101,420,12,NULL,50,0);
  48.      st=CreateStringGadget(win,150,113,420,12,NULL,50,0);
  49.      la=CreateStringGadget(win,150,125,40,12,NULL,4,0);
  50.      pl=CreateIntegerGadget(win,195,125,80,12,NULL,6,0);
  51.      or=CreateStringGadget(win,280,125,290,12,NULL,50,0);
  52.      co=CreateStringGadget(win,150,141,420,12,NULL,31,0);
  53.      WriteText(rp,40,25,"ATUtilities - Shareware-Registrierung:");
  54.      WriteText(rp,10,40,"Informationen, wie Sie die ATUtilities registrieren lassen, finden Sie in");
  55.      WriteText(rp,10,50,"der Datei \"Registrierung.dok\". Haben Sie ihre Registrierkarte zurück,");
  56.      WriteText(rp,10,60,"so lesen Sie vor der Dateneingabe auf jeden fall die Eingabehinweise!");
  57.      WriteText(rp,10,75,"Klicken Sie \"Abbruch\" oder geben Sie Ihre Registrierdaten ein.");
  58.      WriteText(rp,20,98,"Vorname:");
  59.      WriteText(rp,20,110,"Nachname:");
  60.      WriteText(rp,20,122,"Str./Nummer:");
  61.      WriteText(rp,20,134,"Land/Plz./Ort:");
  62.      WriteText(rp,20,150,"Reg. Code:");
  63.      ende=FALSE;
  64.      while(ende==FALSE)
  65.       {
  66.        WaitPort(win->UserPort);
  67.        msg=GetMsg(win->UserPort);
  68.        Class=msg->Class;
  69.        gad=msg->IAddress;
  70.        ReplyMsg(msg);
  71.        switch(Class)
  72.         {
  73.          case CLOSEWINDOW:
  74.            ende=TRUE;
  75.           break;
  76.          case GADGETUP:
  77.            switch(gad->GadgetID)
  78.             {
  79.              case 1:
  80.                Kill(vn,50);
  81.                Kill(nn,50);
  82.                Kill(st,50);
  83.                Kill(la,4);
  84.                Kill(pl,6);
  85.                Kill(or,50);
  86.                Kill(co,31);
  87.                strcpy(&Kunde.Vorname,vn);
  88.                strcpy(&Kunde.Nachname,nn);
  89.                strcpy(&Kunde.Straße,st);
  90.                strcpy(&Kunde.Land,la);
  91.                strcpy(&Kunde.Postleitzahl,pl);
  92.                strcpy(&Kunde.Ort,or);
  93.                strcpy(&Kunde.Code,co);
  94.                RefreshGadgets(win->FirstGadget,win,NULL);
  95.                i=0;
  96.                z=GetStringCode(vn,CODE_VN);
  97.                i+=TestCode(co,z,VN1,VN2,VN3,VN4);
  98.                z=GetStringCode(nn,CODE_NN);
  99.                i+=TestCode(co,z,NN1,NN2,NN3,NN4);
  100.                z=GetStringCode(st,CODE_ST);
  101.                i+=TestCode(co,z,ST1,ST2,ST3,ST4);
  102.                z=GetStringCode(la,CODE_LA);
  103.                i+=TestCode(co,z,LA1,LA2,LA3,LA4);
  104.                z=GetStringCode(pl,CODE_PL);
  105.                i+=TestCode(co,z,PL1,PL2,PL3,PL4);
  106.                z=GetStringCode(or,CODE_OR);
  107.                i+=TestCode(co,z,OR1,OR2,OR3,OR4);
  108.                z=GetCodeCode(co);
  109.                i+=TestCodeCode(co,z,CO1,CO2,CO3,CO4);
  110.                if(i!=0)
  111.                 {
  112.                  MultiRequest("Ihre Registrier-Angaben sind fehlerhaft!",
  113.                               "Bitte prüfen Sie die Eingaben!","Okay",NULL);
  114.                 }
  115.                else
  116.                 {
  117.                  ende=TRUE;
  118.                  bool=TRUE;
  119.                 }
  120.               break;
  121.              case 2:
  122.                ende=TRUE;
  123.               break;
  124.              case 3:
  125.                InformationBox("ATUtilities Registrierung - Information",
  126.                               "$VER: Registrierung - Version 4.0",
  127.                               "Copyright (C) 1993 by",
  128.                               "Thomas Dreibholz",
  129.                               "All rights reserved.",
  130.                               "AT:Icons/Register");
  131.               break;
  132.             }
  133.           break;
  134.         }
  135.       }
  136.      DeleteStdWindow(win);
  137.      if(bool==TRUE)
  138.       {
  139.        win=CreateStdWindow("ATUtilities - Shareware-Registrierung",
  140.                            25,25,590,162,CLOSEWINDOW,
  141.                            WINDOWCLOSE|WINDOWDRAG|WINDOWDEPTH|ACTIVATE);
  142.        if(win!=NULL)
  143.         {
  144.          rp=win->RPort;
  145.          if(opal) SetFont(rp,opal);
  146.          SelectStdFPen(rp);
  147.          WriteText(rp,15,25,"Eingetragener Benutzer:");
  148.          WriteText(rp,15,40,&Kunde.Vorname);
  149.          WriteText(rp,15,50,&Kunde.Nachname);
  150.          WriteText(rp,15,65,"Folgende Programme wurden registriert:");
  151.          i=GETPRG(Kunde.Code);
  152.          j=80;
  153.          for(z=0;z<SYS_COUNT;z++)
  154.           {
  155.            if((i & Programs[z].Code) || (Programs[z].Code==0))
  156.             {
  157.              WriteText(rp,15,j,Programs[z].Name);
  158.              j+=10;
  159.             }
  160.           }
  161.          WaitPort(win->UserPort);
  162.          msg=GetMsg(win->UserPort);
  163.          ReplyMsg(msg);
  164.          fh=Open("AT:ATUtilities.reg",MODE_NEWFILE);
  165.          if(fh!=NULL)
  166.           {
  167.            Write(fh,&Kunde,sizeof(struct Kunde));
  168.            Close(fh);
  169.           }
  170.          else
  171.           {
  172.            InfoRequest("Reg-Datei konnte nicht gesichert werden!");
  173.           }
  174.          DeleteStdWindow(win);
  175.         }
  176.        else
  177.         {
  178.          InfoRequest("Kein Speicher für Fenster!");
  179.         }
  180.       }
  181.      if(opal) CloseFont(opal);
  182.     }
  183.    else
  184.     {
  185.      InfoRequest("Kein Speicher für Fenster!");
  186.     }
  187.    CloseLibrary(ATUtilitiesBase);
  188.   }
  189.  else
  190.   {
  191.    printf("Keine ATUtilities-Library!\n");
  192.   }
  193.  CloseLibrary(IntuitionBase);
  194.  CloseLibrary(GfxBase);
  195.  exit(0);
  196. }
  197.  
  198.  
  199. VOID Kill(str,len)
  200.  UBYTE *str;
  201.  UWORD  len;
  202. {
  203.  WORD i;
  204.  
  205.  for(i=len;i>strlen(str);i--)
  206.   {
  207.    str[i]=0x00;
  208.   }
  209.  for(i=(strlen(str))-1;i>0;i--)
  210.   {
  211.    if(str[i]==' ') str[i]=0x00; else break;
  212.   }
  213. }
  214.  
  215.